﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DispatchAssist.BusinessLogical.Model
{
    public class CacheAlertRule
    {

         private List<AlertRule> _list;

         public CacheAlertRule(List<AlertRule> list)
        {
            _list = list;
        }

        public int GetActionFlag(string airPort, int level)
        {
            List<AlertRule> list = _list.Where(f => f.Airport == airPort && f.WarnLevel == level).ToList();
            if (list.Count == 1)
            {
                return list[0].AlertActionFlag; 
            }
            else
            {
                List<AlertRule> defaultValue = _list.Where(f => f.Airport == "0000" && f.WarnLevel == level).ToList();
                return defaultValue[0].AlertActionFlag;
            }

        }
    }

   
}
